package com.hdu.dwh.results;

import com.hdu.dwh.enums.HttpStatusEnum;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;

import java.io.Serializable;

@Data
@EqualsAndHashCode(callSuper = true)
@AllArgsConstructor
@NoArgsConstructor
@Schema(title = "分页结果集处理器")
public class PageResponseResult<T> extends ResponseResult<T> implements Serializable {

    @Schema(description = "当前页")
    private Integer currentPage;

    @Schema(description = "总页数")
    private Integer pages;

    @Schema(description = "页大小")
    private Integer size;

    @Schema(description = "条数")
    private Integer total;

    public PageResponseResult(int page, int pages, int size, int total, T data) {
        super(HttpStatusEnum.SUCCESS.getCode(), true, HttpStatusEnum.SUCCESS.getMessage(), data);
        this.currentPage = page;
        this.pages = pages;
        this.size = size;
        this.total = total;
    }

    public static <T> ResponseResult<T> success(int page, int pages, int size, int total, T data) {
        return new PageResponseResult<>(page, pages, size, total, data);
    }
}
